<template>
    <el-button
        class="panl-button"
        type="primary"
        :loading="disabled"
        :disabled="disabled"
        @click="toJumpUc"
    >
        {{curInfo.addName}}
        <i class="el-icon-edit-outline el-icon--right"></i>
    </el-button>
</template>

<script lang="ts">
import {
    Component,
    Prop,
    Watch,
    Vue
} from 'nuxt-property-decorator'
import {ciipWebUrl} from '~/../config/server.url.conf'
import {validateUserAuthor} from '~/api'
import ValidateLoginConfirm from '~/method/confirm'
@Component({
    name: 'jumpCenterBtn'
})
export default class JumpCenterBtn extends Vue {
    @Prop({
        default: 'el-icon-edit-outline'
    })
    icon!: string
    @Prop({
        default: true
    })
    showIcon!: boolean
    @Prop({
        default: 's'
    })
    type!: string
    @Prop()
    info!: any
    baseInfo: any = {
        s: {
            type: 's',
            path: '/qiao/s',
            value: 'SERVICE',
            addName: '发布服务'
        },
        d: {
            type: 'd',
            path: '/qiao/d',
            value: 'DEMAND',
            addName: '发布需求'
        },
        e: {
            type: 'e',
            path: '/community/expert',
            value: 'EXPERT',
            addName: '成为专家'
        }
    }
    curInfo: any = null
    disabled: boolean = true
    created () {
        this.curInfo = this.info || this.baseInfo[this.type]
    }
    toJumpUc () {
        const item = this.curInfo
        const confirm = new ValidateLoginConfirm({that: this})
        confirm.toJumpUc(item.value, item.path, item.addName)
    }
    @Watch('$store.state.userNum', {immediate: true, deep: true})
    init (nv: number) {
        if (nv > 0) {
            this.disabled = false
        }
    }
}
</script>
